package gscore

import (
	"net/http"
	_ "net/http/pprof"
	"strconv"
	"sync"

	"gitee.com/crack007/goose/gslog"
)

var once = sync.Once{}

func BootstrapPprof(port uint16) {
	if port == 0 {
		return
	}

	once.Do(func() {
		go func() {
			gslog.Info("Pprof server listen: %d", port)
			err := http.ListenAndServe(":"+strconv.Itoa(int(port)), nil)
			if err != nil {
				gslog.Error("Pprof start error: %s", err.Error())
			}
		}()
	})

}
